﻿namespace TopHero
{
    public class Road : CellEntity
    {
        internal Road(Game game, Cell cell) : base(game, cell)
        {

        }

        private void Spawn()
        {
            int random = Random.Instance.Next(0, 100);
            if (random < 40)
            {
                Monster monster = new Monster(_game);
                monster.position = position;
                monster.Start();
                _cell.AddMonster(monster);
            }
        }

        internal override void Start()
        {
            _viewObject = _game.viewService.CreateRoadCellView();
            _viewObject.Link(this);
        }

        internal override bool HandleMessage(Telegram telegram)
        {
            if (telegram.msg == MessageType.AddLoop)
            {
                Spawn();
                return true;
            }

            return false;
        }
    }
}